package com.yizhang.pattern.template;

/**
 * @Author: yi.zhang
 * @CreateTime: 2025-08-29 10:54:05
 * @Description: 饮料抽象类
 */
public abstract class Beverage {

    public final void prepare() {
        boilWater();
        pourInCup();
        brew();
        if (customerWantsCondiments()) {
            addCondiments();
        }
    }

    private void boilWater() {
        System.out.println("将水煮沸");
    }

    private void pourInCup() {
        System.out.println("将水倒入杯中");
    }

    /**
     * 冲泡
     */
    protected abstract void brew();

    /**
     * 添加调味料
     */
    protected abstract void addCondiments();

    /**
     * 是否加入调味料
     * @return
     */
    protected boolean customerWantsCondiments() {
        return true;
    }
}
